package david.java.flink.join.dataSource;

import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.source.SocketTextStreamFunction;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

/**
 * @Description: nc -l 7777
 * @Author: David
 * @Date: Create in 10:55 上午 2021/11/8
 */
public class Test {

    public static void main(String[] args) throws Exception {

        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        DataStreamSource<String> data = env.addSource(new SocketTextStreamFunction("127.0.0.1", 7777, ",", 3));

        SingleOutputStreamOperator<String> map = data.map((MapFunction<String, String>) value -> {
            System.out.println(value);
            return value;
        });


        map.print();


        env.execute("test");




    }

}
